package org.gwc.ioc_04;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class Mysql {

    /**
     * 普通属性赋值
     * 1、直接赋值
     * 2、通过@Value进行配置，但这个一般结合.properties配置文件使用
     *    @Value("${user:gwc}") user为配置文件中的键，gwc为默认值
     */
    private String name = "gwc";

    @Value("${user:gwc}")
    private String mysqlUser;
    @Value("${password}")
    private String mysqlPassword;

    @Override
    public String toString() {
        return "Mysql{" +
                "name='" + name + '\'' +
                ", mysqlUser='" + mysqlUser + '\'' +
                ", mysqlPassword='" + mysqlPassword + '\'' +
                '}';
    }
}

